package com.roncoo.ysq.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.roncoo.ysq.entity.HomeGps;
import com.roncoo.ysq.dao.HomeGpsMapper;
import com.roncoo.ysq.service.IHomeGpsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.junit.platform.commons.util.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yuanshuaiqiang
 * @since 2021-03-22
 */
@Service
public class HomeGpsServiceImpl extends ServiceImpl<HomeGpsMapper, HomeGps> implements IHomeGpsService {

    @Resource
    private HomeGpsMapper homeGpsMapper;
    @Override
    public IPage<Map> findAll(HomeGps gTitle, Page page) {
        page.setSize(4);
        QueryWrapper<HomeGps> wrapper = new QueryWrapper<>();
        if (StringUtils.isNotBlank(gTitle.getGTitle())){
            wrapper.like("g_title",gTitle.getGTitle());
        }
        if (gTitle.getStatus()!=null){
            wrapper.eq("status",gTitle.getStatus());
        }
        IPage<Map> all=homeGpsMapper.findAll(page,wrapper);
        return all;
    }

    /**
     * before 查询数据
     * @return
     */
    @Override
    public List<HomeGps> findByStatus() {
        QueryWrapper<HomeGps> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("status",0);
        List<HomeGps> homeGps = homeGpsMapper.selectList(queryWrapper);
        return homeGps;
    }
}
